using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Practices.ObjectBuilder2;
using Common.Core;

namespace Common.Unity.Extensions.Configuration
{
	class ObjectConfigurationStrategy : BuilderStrategy
	{
		public override void PostBuildUp(IBuilderContext context)
		{
			if ( context.Existing != null )
			{
				IObjectConfiguratorPolicy policy = context.Policies.Get<IObjectConfiguratorPolicy>( context.BuildKey );
				if ( policy != null )
				{
					foreach ( IObjectConfigurator configurator in policy.Configurators )
					{
						configurator.Configure( context.Existing );
					}
				}
			}
			base.PostBuildUp(context);
		}
	}
}